From: Olaf Hering Date: Fri, 10 Jun 2011 08:47:25 +0000 (+0200) Subject: xenpaging: add helper function for unlinking pagefile X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~10135 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=3ea71e936f7e5a42a2e4c4695d92179fa9ddaff1;p=xen.git xenpaging: add helper function for unlinking pagefile Unlink pagefile in the signal handler and also in the exit path. This does not leave a stale pagefile if an error occoured. Signed-off-by: Olaf Hering Committed-by: Ian Jackson --- diff --git a/tools/xenpaging/xenpaging.c b/tools/xenpaging/xenpaging.c index 2af3a05ec7..72daaad164 100644 --- a/tools/xenpaging/xenpaging.c +++ b/tools/xenpaging/xenpaging.c @@ -41,11 +41,20 @@ static char filename[80]; static int interrupted; -static void close_handler(int sig) + +static void unlink_pagefile(void) { - interrupted = sig; if ( filename[0] ) + { unlink(filename); + filename[0] = '\0'; + } +} + +static void close_handler(int sig) +{ + interrupted = sig; + unlink_pagefile(); } static int xenpaging_mem_paging_flush_ioemu_cache(xenpaging_t *paging) @@ -716,6 +725,7 @@ int main(int argc, char *argv[]) out: close(fd); + unlink_pagefile(); free(victims); /* Tear down domain paging */